<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../templates/StakeholderPortalTemplate.xhtml">
    <ui:define name="content">
        <h:form>
            <f:view beforePhase="#{stakeholderULPManagerBean.initAddULPItem}"/>
            <h1>Apply for a ULP Item</h1>
            <p:panel id="panel" header="Apply for a ULPItem">
                <p:ajaxStatus style="width:16px;height:16px;">
                    <f:facet name="start">
                        <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value="" />
                    </f:facet>
                </p:ajaxStatus>
                <p:messages />

                <h:panelGrid columns="3" columnClasses="column" cellpadding="5">

                    <h:outputText value="ULP Item Name: " />
                    <p:inputText required="true" requiredMessage="ULPItem name is required." id="ULPItemName" value="#{stakeholderULPManagerBean.ULPItem.name}">
                        <p:ajax event="blur" update="ULPItemNameMsg" />
                    </p:inputText>
                    <p:message id="ULPItemNameMsg" for="ULPItemName" />

                    <h:outputText value="Maximum Issued Quantity: " />
                    <p:inputText required="true" requiredMessage="Minimum issued quantity is required." id="maximumIssuedQuantity" value="#{stakeholderULPManagerBean.ULPItem.maxQuantity}">
                        <p:ajax event="blur" update="maximumIssuedQuantityMsg" />
                    </p:inputText>
                    <p:message id="maximumIssuedQuantityMsg" for="maximumIssuedQuantity" />

                    <h:outputText value="Offer from: " />
                    <p:calendar id="startDate" value="#{stakeholderULPManagerBean.ULPItem.validFrom}"/>
                    <p:message id="startDateMsg" for="startDate" />

                    <h:outputText value="Offer until: " />
                    <p:calendar id="endDate" value="#{stakeholderULPManagerBean.ULPItem.validUntil}"/>
                    <p:message id="endDateMsg" for="endDate" />

                    <h:outputText value="Item voucher validity period: " />
                    <h:selectOneMenu value="#{stakeholderULPManagerBean.ULPItem.validPeriod}" id="validPeriod" >
                        <f:selectItem itemLabel="1 month" itemValue="1"></f:selectItem>
                        <f:selectItem itemLabel="2 months" itemValue="2"></f:selectItem>
                        <f:selectItem itemLabel="3 months" itemValue="3"></f:selectItem>
                        <f:selectItem itemLabel="4 months" itemValue="4"></f:selectItem>
                        <f:selectItem itemLabel="5 months" itemValue="5"></f:selectItem>
                        <f:selectItem itemLabel="6 months" itemValue="6"></f:selectItem>
                        <f:selectItem itemLabel="7 months" itemValue="7"></f:selectItem>
                        <f:selectItem itemLabel="8 months" itemValue="8"></f:selectItem>
                        <f:selectItem itemLabel="9 months" itemValue="9"></f:selectItem>
                        <f:selectItem itemLabel="10 months" itemValue="10"></f:selectItem>
                        <f:selectItem itemLabel="11 months" itemValue="11"></f:selectItem>
                        <f:selectItem itemLabel="12 months" itemValue="12"></f:selectItem>                                   
                    </h:selectOneMenu>
                    <p:message id="validPeriodMsg" for="validPeriod" />

                    <h:outputText value="Image URL: " />                     
                    <p:fileUpload id="imageURL" fileUploadListener="#{stakeholderULPManagerBean.handleULPItemImageUpload}" 
                                  allowTypes="*.jpg;*.png;*.gif;" description="Images" sizeLimit="524288" update="imageURLMsg"/>
                    <p:message id="imageURLMsg" for="imageURL"/> 
                </h:panelGrid>
                <br/>
                <p:separator />
                <h3>Pricing and commission details</h3>
                <h:panelGrid columns="3" columnClasses="column" cellpadding="5">
                    <h:outputText value="Cost of the item (SGD): " />
                    <p:inputText required="true" requiredMessage="Cost of the item is required." id="costOfItem" value="#{stakeholderULPManagerBean.ULPItem.costOfItem}">
                        <p:ajax event="blur" update="costOfItemMsg" />
                    </p:inputText>
                    <p:message id="costOfItemMsg" for="costOfItem" />                     
                </h:panelGrid>
            </p:panel>

            <br/>
            <br/>

            <p:fieldset id="descriptionField" legend="Description" toggleable="true" toggleSpeed="500" >
                <h:outputText value="Description: " />
                <p:editor value="#{stakeholderULPManagerBean.ULPItem.description}" widgetVar="descriptionEditor" width="600"/>
            </p:fieldset>

            <br/>
            <br/>

            <p:fieldset id="hightlightsField" legend="Highlights" toggleable="true" toggleSpeed="500">
                <h:outputText value="Highlights: " />
                <p:editor value="#{stakeholderULPManagerBean.ULPItem.highlight}" widgetVar="highlightsEditor" width="600"/>          
            </p:fieldset>

            <br/>
            <br/>

            <p:fieldset id="fineprintField" legend="Fine Print" toggleable="true" toggleSpeed="500">
                <h:outputText value="Fine Print: "/>
                <p:editor value="#{stakeholderULPManagerBean.ULPItem.fineprint}" widgetVar="fineprintEditor" width="600"/>                   
            </p:fieldset>
            <br/>
            <br/>

            <p:fieldset id="stakeholderRemarks" legend="Add a remark" toggleable="true" toggleSpeed="500">
                <h:outputText value="Add a remark: "/>
                <p:inputTextarea value="#{stakeholderULPManagerBean.ULPItem.remarkFromStakeholder}" style="width:600px"/>                   
            </p:fieldset>
            <br/>
            <br/>
            <p:commandButton id="submitbutton" value="Submit" update="panel" actionListener="#{stakeholderULPManagerBean.createULPItem}" ajax="false" />
        </h:form>
    </ui:define>
</ui:composition>

